﻿using System;
using System.Web.UI.HtmlControls;
using Besture.Bll;
using Besture.Common;
using Besture.Common.Definition;
using System.Data;

namespace Besture.UI.ClassHelper
{
    public partial class SeoPage : BaseClientPage
    {
        protected override void OnLoad(EventArgs e)
        {
            //SEO
            string currentPageName = Page.Request.Url.Segments[Page.Request.Url.Segments.Length - 1];
            string pageKey = currentPageName.Substring(0, currentPageName.LastIndexOf("."));

            DataTable dt = new SeoDac().GetDataBySeoKey(pageKey);
            if (dt!=null&&dt.Rows.Count > 0)
            {
                Page.Title = dt.Rows[0]["SeoTitle"].ToString();
                HtmlMeta keywordsMeta = new HtmlMeta();
                keywordsMeta.Name = "keywords";
                keywordsMeta.Content = dt.Rows[0]["SeoKeyword"].ToString();
                Page.Header.Controls.Add(keywordsMeta);

                HtmlMeta discriptionMeta = new HtmlMeta();
                discriptionMeta.Name = "description";
                discriptionMeta.Content = dt.Rows[0]["SeoDescription"].ToString();
                Page.Header.Controls.Add(discriptionMeta);
            }
            base.OnLoad(e);

        }
    }
}